#include <iostream>
#include <string>
using namespace std;
class calcTask
{
public:
    calcTask() {}
    calcTask(const int &x, const int &y, char &op)
        : _x(x), _y(y), _op(op)
    {
    }
    int mymath(int x, int y, char op)
    {
        int result = 0;
        switch (op)
        {
        case '+':
            result = x + y;
            break;
        case '-':
            result = x - y;
            break;
        case '*':
            result = x * y;
            break;
        case '/':
            if (y == 0)
            {
                cerr << "除零异常" << endl;
                result = -1;
            }
            else
                result = x / y;
            break;
        case '%':
            if (y == 0)
            {
                cerr << "模零异常" << endl;
                result = -1;
            }
            else
                result = x % y;
            break;
        default:
            break;
        }
        return result;
    }
    string operator()()
    {
        int result = mymath(_x, _y, _op);
        char buffer[1024];
        snprintf(buffer, sizeof buffer, "%d %c %d = %d", _x, _op, _y, result);
        return buffer;
    }
    string toTaskString()
    {
        char buffer[1024];
        snprintf(buffer, sizeof buffer, "%d %c %d = ?", _x, _op, _y);
        return buffer;
    }
    int _x;
    int _y;
    char _op;
};
